﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuanLyDoiXe.Lop_du_lieu;

namespace QuanLyDoiXe.lop_doi_tuong
{
    class lop_hoadon
    {
        string MHD,MCTHD,Mxe;
        DateTime Ngaygiaohang,Ngaylaphoadon;
        public lop_hoadon(){}
        public lop_hoadon(string MHD,string MCTHD,string Mxe, DateTime Ngaygiaohang,DateTime Ngaylaphoadon)
        {
            this.MHD = MHD;
            this.MCTHD = MCTHD;
            this.Mxe = Mxe;
            this.Ngaygiaohang = Ngaygiaohang;
            this.Ngaylaphoadon = Ngaylaphoadon;
        }
        #region Các phương thức hoạt động
        public bool taomoi()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if (dl.thucthitruyvan("insert into hoadon values ('" + MHD + "','" + MCTHD + "','" + Mxe + "','" + Ngaygiaohang + "','" + Ngaylaphoadon + "')") == 1)
            {
               lop_ket_noi.huyketnoi();
               return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        public bool capnhat()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if (dl.thucthitruyvan("update hoadon set MCTHD=N'" + MCTHD + "',Mxe='" + Mxe + "',Ngaygiaohang='" + Ngaygiaohang + "',Ngaylaphoadon='" + Ngaylaphoadon + "' where MHD='" + MHD + "'") == 1)
            {
                lop_ket_noi.huyketnoi();
                return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        public bool xoa()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if (dl.thucthitruyvan("delete from hoadon where MHD='" + MHD + "'") == 1)
            {
                lop_ket_noi.huyketnoi();
                return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        #endregion
    }
}
